﻿using Manager.Database;
using Manager.Model;


namespace Manager.Initializer
{
    public class UserInitializer
    {
        private readonly PCCSContext _context;

        public UserInitializer(PCCSContext context)
        {
            _context = context;
        }


        public async Task InitializeAsync()
        {
            if (!_context.users.Any())
            {
                // 如果用户不存在，创建一个新用户
                var user = new User
                {
                    username = "admin",
                    password = "admin",
                    sex = 1,
                    nickname = "管理员",
                    mobile = "123456789",
                    state = 1,
                };
                _context.users.Add(user);
                await _context.SaveChangesAsync();
            }
        }
    }
}
